<include file="public/header" />
</head>
<body>
<div style="margin: 15px;" class="user-main">

	 <form class="layui-form mt20 "  action="{:url('Admin/useradd')}"  >

	 <div class="layui-form-item">
			<label class="layui-form-label"><span class="red">*</span>选择权限角色:</label>
			<div class="layui-input-inline layui-wd">
				<select name="role_id" lay-filter='role'  >
				 <foreach name="role" item="vo">
					<option value="{$vo.id}" <if condition="$vo['id'] eq $msg['role_id']"> selected="selected"</if>>{$vo.name}</option>
				 </foreach>
				</select>
			</div>
		</div>

		 <div class="layui-form-item" >
			 <label class="layui-form-label"><span class="red">*</span>选择代理地址:</label>
			 <div class="layui-input-inline layui-wd" id='adds'  >
				 <select name="city" xm-select="city" xm-select-radio xm-select-search xm-select-search-type="dl" >
						{$data}
				 </select>
			 </div>
		 </div>
		<div class="layui-form-item ">
			<label class="layui-form-label"><span class="red">*</span>用户登录账号:</label>
			<div class="layui-input-inline layui-wd">
				<input type="text"  name="user_login" placeholder="请输入用户登录账户!" class="layui-input"  lay-verify="required" />
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span class="red">*</span>登录密码:</label>
			<div class="layui-input-inline layui-wd" >
				<input type="password"  name="user_pass"  placeholder="请输入密码" class="layui-input"  lay-verify="required|pass" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span class="red">*</span>确认密码:</label>
			<div class="layui-input-inline layui-wd" >
				<input type="password"  name="checkpwd"  placeholder="请再次输入密码" class="layui-input"   lay-verify="required|pass" >
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label"><span class="red">*</span>用户昵称:</label>
			<div class="layui-input-inline layui-wd">
				<input type="text" value="{$msg.nicename}" name="nicename" placeholder="请输入用户昵称" class="layui-input "   lay-verify="required|username"  maxlength="12" >
			</div>
		</div>

		<div class="clear"></div>


		<div class="layui-input-block mt20">
			    <button class="layui-btn layui-btn-danger  fr mr100"  lay-submit  lay-filter="iframebtn">确认保存</button>
		</div>

	</form>
</div>
<include file="public/footer" />
<script>
	var formSelects = layui.formSelects;
	form.render();
	//监听switch
	form.on('select(role)', function(data) {
		console.log(data.value); //得到被选中的值
		var url = "{:url('Admin/getaddress',['level'=>ukid])}";
		url = url.replace('ukid', data.value);
		$.getJSON(url,function(result){
			if(result.status == 1){
				var str="<select name=\"city\" xm-select=\"city\" xm-select-radio xm-select-search xm-select-search-type=\"dl\" >";
				$.each(result.data,function(index,value){
					console.log(value);
					str+="<option value="+value.id+" >"+value.name+"</option>";
				});
				str+="</select>";
				$("#adds").html(str);
				console.log($("#adds").html());
				formSelects.render();
			}else{
				layer.msg(result.msg);
			}
		});
	});
</script>
</body>
</html>